How to install the legit minecraft safe and free?

Everytime i install a minecraft set up thing its never safe ad i get notifications that it could harm my laptop. Is there a way to get minecraft legitimently free?

No. You can't get a pirated program in any legitimate way.

As Oscar noted, getting something "legit" by stealing it doesn't really go together.

My advice would be to read the comments/reviews of a torrent before you download it.
Also the computer usually gives that error regardless of if it's a safe program or not.

Minecraft.net
It's $30.00 if I remember rightly.