That's the idea behind "variolation", which was used before there were vaccines. It's risky, since you might get infected anyway, or perhaps the dose isn't enough to work.
Making strong guarantees that people will become immune and won't be infected is part of what makes coming up with a vaccine hard. It's apparently pretty easy and quick to come up with vaccine candidates.
It was a controlled infection with Smallpox, by scraping the skin with pus or scab powder from an infected person. Cowpox is what makes the smallpox vaccine.
If we have a vaccine candidate that is safe, is there any reason not to give it in mass before knowing if it works? The only thing I can come up with is it takes longer to prove safety than effectiveness, but I don't much about this.
Also, during the H1N1 scare a vaccine used in Europe caused some people to develop narcolepsy (though perhaps more would have gotten it from the virus itself without a vaccine). It can be hard to determine that something is “safe” quickly.
SARS-CoV-2 is also at a really awkward point in the fatality curve (with the best estimate of the IFR being around 1%) that you really want to do something, but you also can't really accept a significant chance of that something having a significant side effect.
Making strong guarantees that people will become immune and won't be infected is part of what makes coming up with a vaccine hard. It's apparently pretty easy and quick to come up with vaccine candidates.