Does it mean "how can I know?" If not, what's it mean?

Native speaker’s answer
Rebecca
Yes, that's a good guess! When someone says "how was I to [verb]," it's basically expressing the difficulty of them being able to do something. The lyrics "how was I to know" means "how was I supposed to know" or "how could I have known," expressing the singer's opinion that it would have been difficult or impossible for him to know the things mentioned later (that his lover would be understanding and fair). Ex: How was I to know that the stock market would crash? I would have gotten out sooner. Ex: How was I to know that it was going to rain? The forecast said it would be sunny.