I bought the domain with 1and1, and in the DNS settings it said to type in my IP address
Either (A) 1and1 is doing DNS service for you (the Internic points to 1and1 as your authoritative nameserver) and 1and1 has an A record for your machine's IP address or (😎 1and1 has delegated DNS service to your machine.
If (A) is true and you can't get to your machine by your domain name, then this would be a routing, port, or network issue, or you are not running server software (like Apache) to listen and respond to requests.
If (😎 then you will need to be hosting DNS service on your local machine and resolving requests for lookups on that domain.
In neither (A) nor (😎 are you required to set up 127.0.0.1 to make your domain work on your local machine. True, that would make it work, but if that's all you wanted, then you didn't need to actually buy the domain at 1and1 in the first place. For example, if I set up www.phpbuilder.com = 127.0.0.1 in my hosts file on my local machine, then whenever I type in the domain (which I clearly do not own) into my web browser, I will just go to my local machine. If I set up a web site in Apache on my local machine with a picture of my dog, then going to www.phpbuilder.com would bring me to my fake web site, not the real site.
If you actually own your domain name (which you do), then some machine is made responsible for converting the name (something.yourdomain.com) into an IP address. So when you try to go to that domain name from your local computer, the authoritative machine will resolve "something.yourdomain.com" into the IP address of your machine. If there is no server software (like Apache) set up to respond to requests for that domain, then "getting" to that machine isn't going to do you any good - you're going to "arrive" there but the machine (your own) isn't going to respond.