You are asked those things for (as far as I can tell) two reasons. One is to simply observe your demeanor. The idea is that someone who is concealing something will give conflicting, vague, or over-detailed answers to simple questions.
The other is to seek real information that can be used to distinguish smugglers from travelers. For example, I once had the following conversation with the Border lady:
"How long was your trip?"
"10 days."
"Where did you go?"
"The Golden Triangle: northern Thailand and eastern Burma."
"Did you travel alone."
"Yes."
"Did you meet anyone while you were traveling?"
"Sure, dozens of people."
Needless to say, everything I was carrying was examined minutely. I didn't know you could disassemble a Bic pen.
Do you have to answer? No, you can decline to answer if you're a US citizen, but think about it.
In general, you should be extremely reluctant to answer any questions about your own activities from law enforcement. You might think you have done nothing wrong, but do you have the US Code committed to memory? They say the average American commits three felonies a day; you don't want to accidentally confess to yours.
But if you go through a border-check, they are going to ask you questions. They aren't trying to incriminate innocent people; they are trying to sort out the smugglers. If you don't answer, they have to throw you on the maybe-smuggler category and go through all your belongings.
So my advice:
- If you have done anything on your journey that might jam you up with the Feds (visited Cuba, traded with a sanctioned country) but your luggage is squeaky clean, decline to answer questions and let them rummage through your underwear.
- If you were a naughty boy and you are bringing back a few grams of fond memories, smile politely and say, "I just lay on the beach for two weeks."
- Otherwise, answer the questions politely, accurately, and concisely.