It's possible to connect a microphone or guitar directly to your computer using an adapter, but it's not recommended, as this will result in poor sound and potential damage to your computer. You will need an audio interface or sound card to properly record music on your computer. A sound card/audio interface handles sound coming in and out of the computer, resulting in high-quality sound with very little latency. A sound card is an internal device, while an audio interface sits outside of your computer. You can use a proper audio interface or sound card to record a variety of instruments, including guitar, keyboards, drum machines, etc.
It's acceptable to listen to MP3s and podcasts on the basic speakers that come with your desktop or laptop, but if you're going to be recording music on your computer, you'll need high-quality speakers and headphones to serve as monitors. Recording engineers use top-shelf speakers and headphones to monitor recordings for crystal clear sound clarity. A great set of monitors will reveal flaws in a recording you may not be able to discern using a low-quality set of speakers.
Recording music takes up more space on your computer than running a word processor or playing a card game. If you plan on recording songs longer than 5 seconds long, you'll need to invest in an external hard drive to save your work. You can use this extra hard drive to save your recordings in a safe place in the event that your computer gets a virus. Using an external hard drive to save your recordings will also free up space on your computer, resulting in better performance of your recording program.
Trying to record music on your computer without a microphone is like a painter trying to paint a picture without a brush. A microphone picks up sound waves and converts them into audio signals. You need a microphone to transmit raw sound to your interface so it can eventually reach your computer, whether you're recording vocals or piano. It is the first piece of equipment in a recording chain. For this reason, you need a quality microphone to ensure the best end result in recording. You can't turn a poor signal picked up by a microphone into recording gold.