Good question! Viola initially says she wants to serve Olivia, because Olivia has recently lost a brother:
A virtuous maid, the daughter of a count
That died some twelvemonth since: then leaving her
In the protection of his son, her brother,
Who shortly also died...
Viola, of course, sees Olivia as a kindred spirit: Viola fears at this point that her brother, Sebastian, has died. Yet the Captain then tells her Olivia
...will admit no kind of suit
No, not the Duke's.
Viola wants to keep her estate unknown, until such a time as she knows better what to do - and, perhaps, until she knows whether Sebastian has survived. So, she resolves,
I'll serve this duke
Thou shalt present me as an eunuch to him...
Why a eunuch? Well, because it explains her feminine voice. And, in Renaissance courts, eunuchs were often employed as musicians and singers: and Viola goes on to say that she can sing and play several instruments.