I have invented a device which uses earth's magnetic field to generate a good and usable amount of electricity more efficient than solar cells.Is this device patent-able or this has been already patented?
I know nothing about the prior art in this field. That is something which really can only be assessed by a patent search. Nevertheless, I would be reasonably confident in assuming that there is no enabling prior art in this.
Assuming my assumption is correct, your invention would in principle be patentable. However, it would not have an easy ride.
A patent will only be granted in the US if an invention is useful (35 USC § 101). This is usually a low bar. However, it is particularly salient when it comes to machines which produce "free power".
There is a long discussion about the requirement for usefulness at MPEP § 2107. However, one passage which succinctly summarises the position would be:
Rejections under 35 U.S.C. 101 based on a lack of credible utility have been sustained by federal courts when, for example, the applicant failed to disclose any utility for the invention or asserted a utility that could only be true if it violated a scientific principle, such as the second law of thermodynamics, or a law of nature, or was wholly inconsistent with contemporary knowledge in the art.
I suspect that your invention would be regarded as wholly inconsistent with contemporary knowledge in the art. Therefore, if you applied for a US patent, I would expect you would receive an objection that your invention is not useful. You would then be required to provide sufficient evidence to prove that your invention works in the manner you suggest it does. This may involve testing by an independent agency.
If you can show that your invention works to achieve a useful result, I can't see any reason why you couldn't get a patent for it. But if you can generate a substantial amount of free power from the Earth's magnetic field, I suspect getting a patent would be the least of your achievements.