OLYMPIA — Washington can tax the sale of stocks and other investments, freeing the state to collect more than $500 million a year to pay for child care programs, the state Supreme Court ruled Friday.