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.