arbiter bring down the three node mongodb replica set
When I take the arbiter offline (killing the instance), both two data
  nodes become secondary (they were primary and secondary).


In this case, when the arbiter(_id = 3) goes down, The member with _id equals to 4 has Priority and votes as 0, so it cannot become primary and cannot vote in the election and the Majority(2 votes) cannot be established. So both the nodes becomes secondary.


  When I take the primary offline (killing the instance), the secondary
  and arbiter remain secondary and arbiter. There is no voting to select
  the new primary.


In this case, when the Primary(_id = 5) goes down, The member with _id equals to 4 has Priority, so it cannot become primary. Because of this the secondary
and arbiter remains as secondary and arbiter.

How to design this replica set to work better?

Make the Priority and votes of the node(_id = 4) to 1, it will fix both the scenarios.