To record incoming instruments
For guitar, neither is correct.
A USB audio interface with a (high impedance) “guitar” or “instrument” input is best. The [u]Behringer UCG102[/u] is popular and inexpensive.
Or there are lots of [u]audio interfaces[/u] with switchable mic/line/instrument inputs. (Often the “line input” on an audio interface is high impedance with some gain so it doubles as a guitar input, or it sometimes they have a 1/4-inch-XLR combo jack and it’s high-impedance when a 1/4-inch plug is plugged-in, etc.)
If you don’t want to buy an interface you can just try both inputs to see which one works best. The line-input may be “too quiet”, but try boosting the volume with the Amplify effect after recording before you compare the two.
As a rule the mic input on a regular soundcard or laptop is worthless for quality recording. It’s often low quality (noisy) and it’s simply the wrong interface for any good stage/studio microphone (which uses a balanced low-impedance connection).
Keyboards usually have a line-output, or you can use a headphone output into line-in.
With electric guitar, the amp & cabinet are “part of the guitar sound” and pros often record guitar with a mic in front of the guitar cabinet. But that means you need a guitar amp/cabinet that you “like”, plus you need a good mic & interface and a quiet “studio” to record in.
You can also get amp/cabinet simulator software plug-ins (AKA “amp [u]sims[/u]”). It’s also common for pros to record direct and use a sim, or to record both ways on separate tracks. That way, they can try different sims after recording (or they can blend the microphone track with the sim, etc.). And if you don’t already own “the amp of your dreams”, it’s a lot more economical to use a sim. And with a sim, you don’t have to crank it up and bother the neighbors.